//
//  BasicViewController.m
//  美食百科
//
//  Created by dllo on 16/1/23.
//  Copyright © 2016年 doll. All rights reserved.
//

#import "BasicViewController.h"

@interface BasicViewController ()

@end

@implementation BasicViewController
-(void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"模式" object:nil];
    [_color release];

    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationAction:) name:@"模式" object:nil];
    
    NSUserDefaults *userDefaults = [[NSUserDefaults alloc] init];
    
    BOOL night = [userDefaults boolForKey:@"夜间模式"];
    
    if (!night) {
        self.view.backgroundColor = [UIColor whiteColor];
        self.view.alpha = 1;
        
        self.color = [UIColor blackColor];
        [self.view setNeedsDisplay];
    }else
    {
        self.view.backgroundColor = [UIColor colorWithRed:0.251 green:0.255 blue:0.412 alpha:1.00];
       // self.view.alpha = 0.7;
        
        self.color = [UIColor whiteColor];
        [self.view setNeedsDisplay];
    }

}
-(void)notificationAction:(NSNotification *)notification
{
    NSString *mode = notification.userInfo[@"Mode"];
    
    if ([mode isEqualToString:@"白天"]) {
        self.view.backgroundColor = [UIColor whiteColor];
        self.view.alpha = 1;
        self.color = [UIColor blackColor];
        [self.view setNeedsDisplay];
    }else
    {
        self.view.backgroundColor = [UIColor colorWithRed:0.251 green:0.255 blue:0.412 alpha:1.00];
       // self.view.alpha = 0.7;
        self.color = [UIColor whiteColor];
        [self.view setNeedsDisplay];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
